#[test]
fn test_bool() {
    let praise_the_borrow_checker = true;

    // 使用 `if` 有条件
    if praise_the_borrow_checker {
        println!("oh, yeah!");
    } else {
        println!("what?!!");
    }

    // ... 或者，匹配模式
    match praise_the_borrow_checker {
        true => println!("keep praising!"),
        false => println!("you should praise!"),
    }
}

#[test]
fn test_bool_ref() {
    let x = true;
    let y = &x;
    println!("{}", y);
    let _x = false;
    println!("{}", y);
}

#[test]
fn test_bool_then() {
    let mut a = 0;
    let x = true;

    x.then(|| { a += 1; });
    false.then(|| { a += 1; });

// `a` 增加一次，因为闭包被 `then` 懒惰地评估。
    assert_eq!(a, 1);
}


#[test]
fn test_bool_then_some() {
    let mut a = 0;
    let mut function_with_side_effects = || { a += 1; };

    true.then_some(function_with_side_effects());
    false.then_some(function_with_side_effects());

    println!("{}", a);
}